package com.song.tradition.page.book

import android.app.Person
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavController
import androidx.navigation.NavHostController
import com.song.tradition.R
import com.song.tradition.entity.StoryData
import com.song.tradition.entity.bookDataList
import com.song.tradition.entity.personDataList
import com.song.tradition.entity.swiperData
import com.song.tradition.page.components.BookCard
import com.song.tradition.page.components.PersonCard
import com.song.tradition.page.components.ScreenRoute
import com.song.tradition.page.components.Swiper
import com.song.tradition.page.components.TitleWithMoreTab
import com.song.tradition.ui.theme.customBgColor

@Composable
fun BookScreen(
    navController: NavHostController,

    ) {
    LazyColumn(
        modifier = Modifier
            .fillMaxSize()
            .background(customBgColor)
            .padding(vertical = 8.dp, horizontal = 16.dp)
    ) {
        item {
//            轮播图
            Swiper(items = swiperData)
        }
        item {
            BookCardTab(navController)

        }
        item {
            Column(
                modifier = Modifier
                    .fillMaxWidth()
                    .padding(vertical = 5.dp)
            ) {
                Spacer(modifier = Modifier.height(8.dp))
                TitleWithMoreTab(title = "医学大家") {

                }
                Spacer(modifier = Modifier.height(8.dp))
                LazyRow(
                    horizontalArrangement = Arrangement.spacedBy(10.dp),
                ) {
                    items(personDataList.size) { index ->
                        PersonCard(info = personDataList[index], modifier = Modifier.clickable {

                            navController.navigate(ScreenRoute.PersonDetailScreen.route + "/${index}")
                        })
                    }
                }
            }

        }
    }

}

@Composable
fun BookCardTab(navController: NavController) {
    Column(modifier = Modifier.fillMaxWidth()) {
        Spacer(modifier = Modifier.height(8.dp))
        TitleWithMoreTab(title = "医学著作") {

        }
        Spacer(modifier = Modifier.height(8.dp))
        LazyRow(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
            items(bookDataList.size) { index ->
                BookCard(bookData = bookDataList[index]) {
                    navController.navigate(ScreenRoute.BookDetailScreen.route + "/${index}")
                }
            }
        }
    }
}

@Composable
fun PersonCardTab() {

}
